package com.changli07.encapsulation;

public class encapsulation {
    public static void main(String[] args) {
        Animal a = new Animal();
        a.name = "金蝉";
        a.setLegs(4);
        a.say();
    }
}
class Animal{
    String name;
    private int legs;
    public void setLegs(int legs){
        this.legs = legs;
    }
    public void say (){
        System.out.println("My name is " + name+",My legs'num is " + legs);
    }
}
